/*
 * Copyright 2020 The Kubernetes Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

$inter-message-spacing: 0.1875rem;

.kui--data-table-container {
  .kui--data-table-footer-message {
    /* this tells the browser to line wrap according to the width dictated by the rest of the table */
    max-width: 0;
  }
}

.kui--data-table-as-grid {
  .kui--data-table-footer-message {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 0.4375rem;
  }
}

/* applies only to tables */
.kui--data-table-container {
  .kui--data-table-footer-messages {
    height: auto;
  }
}

@mixin bottom-events-padding {
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 1rem;
  padding-right: 1rem;
}

@mixin bottom-events-first-child-padding {
  padding-top: calc(2 * #{$inter-message-spacing});
}

@mixin bottom-events-last-child-padding {
  padding-bottom: calc(2.5 * #{$inter-message-spacing});
}

@mixin bottom-events-message {
  .marked-content > p,
  p {
    white-space: pre-wrap;
    font-family: var(--font-monospace);
    font-size: 0.75rem;
    margin: 0;
    padding: 0;
  }

  a {
    color: var(--color-base0F);
    font-size: 0.75rem;
    display: inline-flex;
    text-decoration: none; /* See https://github.com/IBM/kui/issues/6739 */
  }
}

/* applies to tables and grids */
.kui--data-table-wrapper {
  .kui--data-table-footer-messages {
    line-height: initial;

    .kui--data-table-footer-message {
      @include bottom-events-message;
    }
  }

  tr:not(.kui--data-table-footer-messages) + .kui--data-table-footer-messages,
  .kui--data-table-toolbar-filler + .kui--data-table-footer-messages,
  .kui--data-table-footer-messages:first-child {
    .kui--data-table-footer-message {
      @include bottom-events-first-child-padding;
    }
  }

  .kui--data-table-footer-messages {
    .kui--data-table-footer-message {
      @include bottom-events-padding;
    }
  }

  .kui--data-table-footer-messages:last-child {
    .kui--data-table-footer-message {
      @include bottom-events-last-child-padding;
    }
  }
}
